<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<link href="${basePath}/css/plugins/jqgriddemo/css/ui.jqgrid-bootstrap.min.css" rel="stylesheet" />
<!doctype html>
<html>
<head>
<style type="text/css">
	.ibox-content{
		border: none;
	}
</style>
</head>
<body class="gray-bg">
<div class="container creditbody">
	 <div class="iboxtitle">
	 	<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;&nbsp;贷后业务>逾期风控>逾期客户表</span>
     </div>
	<div class="ibox-content ibox-zxsearchqu ">
          <div class="row">
              <div class="col-xs-12 col-sm-12 col-md-5 col-lg-5">
             	 <div class="row">
             	 	<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
                   		<select class="select-control" id="bankCode" name="bankCode"></select>
	                 </div>
	                 <div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
	                   	<select type="text"  id="phaseOverdue" name="" class="select-control"> </select>
	                 </div> 
	                 <div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
	                   	 <input  class="form-control" type="text" id="cusName" name="cusName" placeholder="客户名"/>
	                 </div> 
              	 </div>     
              </div>
              <div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
              		<div class="row">
              			<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">  
              				<select type="text"  id="dateOverdueExt" name="" class="select-control" >
								<option value="0">全部逾期客户</option>
		                    	<option value="1">1~30天</option>
		                    	<option value="2">31~60天</option>
		                    	<option value="3">61~90天</option>
		                    	<option value="4">90天以上</option>
		                    </select>
              			</div>
	                    <div class="col-xs-4 col-sm-4 col-md-3 col-lg-3">  
	                    	<select type="text"  id="dateTradeExt" name="" class="select-control" >
		                    	<option value="0">晚于</option>
		                    	<option value="1">早于</option>
		                    	<option value="2">等于</option>
		                    </select>
	                    </div>
	                    <div class="col-xs-4 col-sm-4 col-md-5 col-lg-5">  
	                    	 <input id="dateTrade" name="submitTimeStart" placeholder="放贷日期" onclick="laydate();" class="laydate-icon form-control" >
	                    </div>
                   </div>
               </div>
               <div class="col-sm-12 col-md-3 col-lg-3">
              		<button class="zhixcx" type="button" onclick="query();">执行查询</button>
               </div>
     		</div>
      </div>	
	 
       <div class="ibox-content">
	     	<div class="jqGrid_wrapper">
	         <table id="table_list_1"></table>
	         <div id="pager_list_1"></div>
	    	</div>
	    </div>
	</div>
      
	<!-- public quote -->
    <%@include file="/jsp/comm_js_include.jsp"%>
	<!-- jqGrid -->
    <script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/grid.locale-cn.min.js"></script>	
    <!-- layerDate plugin javascript -->
    <script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
    <!--
    	时间：2017-04-06
    	描述：js
    -->
    <script type="text/javascript">
	    jQuery(function($) { 
	    	getData();
	    	initoverdueDic();
	    });
		    
	    var initoverdueDic=function(){
	    	$.dpAjax({
		    	url:'${basePath}/DataDictionaryController/getEnableList',
	 			data:{},
	 			success: function(datas){
	 				 var result = datas.result.rows;
					 var html='<option value="">选择逾期阶段</option>';
					 var cont = '<option value="">选择贷款方</option>';
				     for(var i=0;i<result.length;i++){
				    	  if(result[i].parentValue == "OverduePhase"){
				    		  html +='<option value="'+result[i].value+'">'+result[i].name+'</option>'
				    	  }
				    	  if(result[i].parentValue == "LoanBank"){
				    		  cont +='<option value="'+result[i].value+'">'+result[i].name+'</option>'
				    	  }
				      }
				     $("#phaseOverdue").html(html);
				     $("#bankCode").html(cont);
					 return;
	              }
		    });
	    }
	    
		var getData = function(){
			var winWidth = $('div.ibox-content').width();
	        var winHeight = document.body.offsetHeight - 300;
	     	var win = winWidth / 7 - 20;
	 	    $.jgrid.defaults.styleUI = 'Bootstrap';
			$("#table_list_1").jqGrid({
	// 			url:'${basePath}/DhOverdueController/queryDueList',
				url:'${basePath}/DhOverdueListController/list',
		       	datatype : "json",
		        colNames : ['主键','客户id','业务id','客户姓名','性别','身份证号','分期金额','币种','持卡人手续费','总期数','入账金额','逾期时间','交易日期', '银行','卡号', '卡余额','月还款额', '贷款额', '当前连续逾期次数','累计逾期次数','剩余金额','手机','电催经办人','银行月还','差额欠款'],
			    colModel : [ 
					{name: 'replaceId',index: 'id',hidden:true},   
					{name: 'cusId',index: 'cusId',hidden:true},   
	                 {name: 'busiId',index: 'busiId',hidden:true},    
		             {name: 'cusName',index: 'cusName',width: 130,align: "center",sorttype: "float"},
		             {name: 'sexDisplay',index: 'sexDisplay',width: 130,align: "center",sorttype: "float"},
		             {name: 'cusIdno',index: 'cusIdno',width: 170,align: "center",sorttype: "float"},
		             {name: 'devideAmount',index: 'devideAmount',width: 130,align: "center",sorttype: "float"},
		             {name: 'currency',index: 'currency',width: 130,align: "center",sorttype: "float"},
		             {name: 'feeTotal',index: 'feeTotal',width: 130,align: "center",sorttype: "float"},
		             {name: 'loanMonth',index: 'loanMonth',width: 130,align: "center",sorttype: "float"},
		             {name: 'amountAmortized',index: 'amountAmortized',width: 130,align: "center",sorttype: "float"},
		             {name: 'dateOverdue',index: 'dateOverdue',width: 150,align: "center",sorttype: "float",formatter:function(a,b,c){
	                   	 return formateStringDate(a);
	                 }},
		             {name: 'dateTrade',index: 'dateTrade',width: 150,align: "center",sorttype: "float",formatter:function(a,b,c){
	                   	 return formateStringDate(a);
	                 }},
		             {name: 'bankCodeDisplay',index: 'bankCode',width: 300,align: "center",sorttype: "float"},
		             {name: 'cardNo',index: 'cardNo',width: 130,align: "center",sorttype: "float"},
		             {name: 'balanceCard',index: 'balanceCard',width: 130,align: "center",sorttype: "float"},
		             {name: 'amountMonthly',index: 'amountMonthly',width: 130,align: "center",sorttype: "float",hidden:true},
		             {name: 'loanAmount',index: 'loanAmount',width: 130,align: "center",sorttype: "float",hidden:true},
		             {name: 'overdueCountContinuous',index: 'overdueCountContinuous',width: 130,align: "center",sorttype: "float"},
		             {name: 'overdueCountTotalReal',index: 'overdueCountTotalReal',width: 130,align: "center",sorttype: "float"},
		             {name: 'amountRemainder',index: 'amountRemainder',width: 130,align: "center",sorttype: "float"},
		             {name: 'telephone',index: 'telephone',width: 130,align: "center",sorttype: "float",formatter:function(a,b,c){
	                   	 return formateStringDate(a);
	                 }},
	                 {name: 'nameOperatorPhone',index: 'nameOperatorPhone',width: 130,align: "center",sorttype: "float"},
	                 {name: 'dcol1',index: 'dcol1',width: 130,align: "center",sorttype: "float"},
	                 {name: 'dcol2',index: 'dcol2',width: 130,align: "center",sorttype: "float"}
		             ],
		           mtype : "post",
		           height: winHeight,
		           width:winWidth,  
		           autowidth: false,
		           shrinkToFit: false,
		           rowNum: 15,
		           rowList: [15, 30, 45],
		           viewrecords: true,
		           pager: "#pager_list_1",
		           hidegrid: false,
		           multiselect : false,		//实现单选    multiboxonly:true   beforeSelectRow: true,
		           multiboxonly:false,
		           altRows:true,
		           altclass:'someClass',
		           beforeSelectRow: false,
		           jsonReader: {
		                root: "result.rows",
		                page: "result.page",
		                total: "result.total",
		                records: "result.records",
		                repeatitems: false,
		                id: "replaceId"
		            },
		            ondblClickRow:function(rowId,v,e)
		              {
		            	  var rowData = $("#table_list_1").jqGrid("getRowData", rowId);
		            	  var busiId = rowData.busiId;
		            	  var cusId=rowData.cusId;
		            	  var overdueCountTotalReal=rowData.overdueCountTotalReal;
		            	  var amountRemainder=rowData.amountRemainder;
		            	  var cusName=rowData.cusName;
		            	  var loanAmount=rowData.loanAmount;
		            	  var overdueId=rowData.replaceId;
		            	  window.location.href="dhCollection.jsp?busiId="+busiId+"&cusId="+cusId+"&amountRemainder="+amountRemainder+"&overdueCountTotalReal="+overdueCountTotalReal+"&cusName="+cusName
		            			  +"&loanAmount="+loanAmount+"&overdueId="+overdueId;   
		              },
		              loadComplete:function(datas){
		            	  if (datas.flag == "100100") {
		                      layer.msg("查询成功!", {icon: 6, time: 1000});
		                      return;
		                  }
		            	  if(datas.flag == '100802') {
		    				  top.location.href = thisLoginUrl;
		    				  return;
		    			  }
	
		            	  layer.msg(datas.message, {icon: 2});
		              }
		      	});
	    	}
		
	  	 //搜索
			var query = function(){
		  		var data={};
		  		var whereSql="";
		  		var dateOverdueExt=$('#dateOverdueExt option:selected').val();
		  		if(dateOverdueExt=="1"){
		  			whereSql=' AND DATEDIFF(NOW(),DATE_OVERDUE)>=1 AND DATEDIFF(NOW(),DATE_OVERDUE)<=30';
		  		}else if(dateOverdueExt=="2"){
		  			whereSql=' AND DATEDIFF(NOW(),DATE_OVERDUE)>=31 AND DATEDIFF(NOW(),DATE_OVERDUE)<=60';
		  		}else if(dateOverdueExt=="3"){
		  			whereSql=' AND DATEDIFF(NOW(),DATE_OVERDUE)>=61 AND DATEDIFF(NOW(),DATE_OVERDUE)<=90';
		  		}else if(dateOverdueExt=="4"){
		  			whereSql=' AND DATEDIFF(NOW(),DATE_OVERDUE)>=91)';
		  		}else{
		  			whereSql=""; 
		  		}
		  		data.cusName=$("#cusName").val();
		  		data.bankCode=$('#bankCode option:selected').val();
		  		data.phaseOverdue=$('#phaseOverdue option:selected').val();
		  		var dateOverdueExt=$('#dateTradeExt option:selected').val();
		  		var dateTrade=$("#dateTrade").val();
		  		if(dateTrade !=null && dateTrade !=""){
			  		if(dateOverdueExt=="0"){
			  			whereSql+=" AND DATE_TRADE >'"+dateTrade+"'";
			  		}else if(dateOverdueExt=="1"){
			  			whereSql+=" AND DATE_TRADE <'"+dateTrade+"'";
			  		}else{
			  			whereSql+=" AND DATE_TRADE ='"+dateTrade+"'";
			  		}
		  		}
		  		
		  		data.whereSql=whereSql;
		    	$("#table_list_1").jqGrid("setGridParam",{
	// 	    		url:'${basePath}/DhOverdueController/queryDueList',
						url:'${basePath}/DhOverdueListController/list',
		  				postData:data,
		  				datatype:"json"
		    	}).trigger("reloadGrid")
	    	}
	  	 
		    window.onresize = function(){
		    	 $("#table_list_1").setGridWidth($(window).width()-80);
		    }
		    
		    var formateStringDate=function(sDate1){
		    	if(!sDate1 || sDate1 == ''){
		    		return '-';
		    	}
		    	if(sDate1.indexOf(".")!=-1){
		    		return sDate1.substring(0,sDate1.indexOf("."));
		    	}
		    	var aDate  =  sDate1.substring(0,sDate1.indexOf(" "));
		    	return aDate;
		    }
    </script>
</body>
</html>
